home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 1997
/
HAM Radio 1997.iso
/
vcls
/
moden
/
addial.int
< prev
next >
Wrap
Text File
|
1996-04-08
|
12KB
|
333 lines
{$G+,X+,F+}
{Conditional defines that may affect this unit}
{$I AWDEFINE.INC}
{*********************************************************}
{* ADDIAL.PAS 1.01 *}
{* Copyright (c) TurboPower Software 1995 *}
{* All rights reserved. *}
{*********************************************************}
unit AdDial;
{-Dialer window}
interface
uses
SysUtils,
WinTypes,
WinProcs,
Messages,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
StdCtrls,
Buttons,
OoMisc,
AdMisc,
AdExcept,
AdPort,
AdModem;
type
{TApdModemDialer options}
TDialerOption = (mdAbortOnVoice, mdAbortOnBusy, mdAbortOnNoCarrier,
mdAbortOnNoDialtone, mdAbortOnError);
TDialerOptions = Set of TDialerOption;
TDialResult = (drNone, drDialing, drConnected, drAborted);
const
{TApdModemDialer settings}
DefDialerOptions = [mdAbortOnNoDialtone, mdAbortOnError];
{TApdDialerDialog settings}
NumStatusLines = 13;
DefMaxDialTries = 10;
DefRetrySecs = 60;
type
{component for dialing phone numbers}
TApdCustomModemDialer = class(TComponent)
protected {private}
{.Z+}
FModem : TApdCustomModem; {modem to use for dialing}
FPhoneNumber : String; {phone number to dial}
FMaxDialTries : Integer; {max # of dial attempts}
FRetrySecs : Integer; {seconds between dial retries}
FDialerOptions : TDialerOptions; {options for dialing}
FDialResult : TDialResult; {result of dial attempt}
FDialing : Boolean; {TRUE if dialer active}
FRetryStart : TNotifyEvent; {before dial retry starts}
FRetryCount : TConnectCountEvent; {when retry counter ticks}
FRetryEnd : TNotifyEvent; {when dial retry is finished}
FCycleDial : TNotifyEvent; {when dial attempt cycled}
FDialStart : TNotifyEvent; {at beginning of dial}
FConnect : TNotifyEvent; {when connection established}
FDialCount : TConnectCountEvent; {when dial timer ticks}
FGotLineSpeed : TLineSpeedEvent; {when connect speed detrmnd}
FBusy : TNotifyEvent; {when modem returns busy}
FVoice : TNotifyEvent; {when modem returns voice}
FError : TNotifyEvent; {when modem returns error}
FNoCarrier : TNotifyEvent; {when modem returns ncarrier}
FNoDialTone : TNotifyEvent; {when modem returns ndialtn}
FDialTimedOut : TNotifyEvent; {when dial attempt times out}
FConnectionEstablished : TNotifyEvent; {when connection is established}
FTooManyTries : TNotifyEvent; {when too many dials tried}
FRetrying : Boolean; {TRUE if retrying dial attempt}
{dialing data}
ComPort : TApdCustomComPort; {communications port}
DialTry : Integer; {current dial try}
DialIdx : Integer; {index of dial start timer trig}
{retry data}
Cycling : Boolean; {TRUE if cycling dial attempt}
RetryIdx : Integer; {index of retry count trigger}
RetryWait : Integer; {# secs left until retry}
{saved event handlers}
SaveTriggerTimer : TTriggerTimerEvent;
SaveModemConnect : TNotifyEvent;
SaveDialCount : TConnectCountEvent;
SaveGotLineSpeed : TLineSpeedEvent;
SaveModemBusy : TNotifyEvent;
SaveModemVoice : TNotifyEvent;
SaveModemError : TNotifyEvent;
SaveModemNoCarrier : TNotifyEvent;
SaveModemNoDialTone : TNotifyEvent;
SaveDialTimedOut : TNotifyEvent;
SaveOnByeBye : TNotifyEvent;
procedure Notification(AComponent : TComponent; Operation : TOperation); override;
procedure PrepareDialing;
{-Start a timer to trigger the beginning of a dial attempt}
procedure RetryDial;
{-Retry the last dial attempt, if possible}
procedure RetryDone;
{-Cleanup after a retry countdown}
{dialer event handlers}
procedure DialerTriggerTimer(Sender : TObject; TriggerHandle : Word);
procedure DialerModemConnect(Sender : TObject);
procedure DialerDialCount(Sender : TObject; Remaining : Word);
procedure DialerGotLineSpeed(Sender : TObject; Speed : LongInt);
procedure DialerModemBusy(Sender : TObject);
procedure DialerModemVoice(Sender : TObject);
procedure DialerModemError(Sender : TObject);
procedure DialerModemNoCarrier(Sender : TObject);
procedure DialerModemNoDialTone(Sender : TObject);
procedure DialerDialTimedOut(Sender : TObject);
procedure DialerModemByeBye(Sender : TObject);
procedure RetryStart; virtual;
procedure RetryCount; virtual;
procedure RetryEnd; virtual;
procedure CycleDial; virtual;
procedure DialStart; virtual;
procedure GotConnect; virtual;
procedure DialCount(Cnt : Word); virtual;
procedure GotLineSpeed(Speed : LongInt); virtual;
procedure GotBusy; virtual;
procedure GotVoice; virtual;
procedure GotError; virtual;
procedure GotNoCarrier; virtual;
procedure GotNoDialTone; virtual;
procedure DialTimedOut; virtual;
procedure ConnectionEstablished; virtual;
procedure TooManyTries; virtual;
procedure SinkHooks;
{-Replace existing ComPort/Modem event handlers with dialer handlers}
procedure RemoveHooks;
{-Remove dialer event handlers and replace with originals}
procedure DialingFinished;
{-Dialing done: shut down dial attempt}
procedure ShutDownOnDestroy;
{-Clean up during the middle of a dial attempt}
public
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
{.Z-}
{dialing data}
property Modem : TApdCustomModem
read FModem write FModem;
property PhoneNumber : String
read FPhoneNumber write FPhoneNumber;
property MaxDialTries : Integer
read FMaxDialTries write FMaxDialTries default DefMaxDialTries;
property RetrySecs : Integer
read FRetrySecs write FRetrySecs default DefRetrySecs;
property DialerOptions : TDialerOptions
read FDialerOptions write FDialerOptions;
property DialResult : TDialResult
read FDialResult;
property Dialing : Boolean
read FDialing;
property Retrying : Boolean
read FRetrying;
{events}
property OnRetryStart : TNotifyEvent
read FRetryStart write FRetryStart;
property OnRetryCount : TConnectCountEvent
read FRetryCount write FRetryCount;
property OnRetryEnd : TNotifyEvent
read FRetryEnd write FRetryEnd;
property OnCycleDial : TNotifyEvent
read FCycleDial write FCycleDial;
property OnDialStart : TNotifyEvent
read FDialStart write FDialStart;
property OnConnect : TNotifyEvent
read FConnect write FConnect;
property OnDialCount : TConnectCountEvent
read FDialCount write FDialCount;
property OnGotLineSpeed : TLineSpeedEvent
read FGotLineSpeed write FGotLineSpeed;
property OnBusy : TNotifyEvent
read FBusy write FBusy;
property OnVoice : TNotifyEvent
read FVoice write FVoice;
property OnError : TNotifyEvent
read FError write FError;
property OnNoCarrier : TNotifyEvent
read FNoCarrier write FNoCarrier;
property OnNoDialTone : TNotifyEvent
read FNoDialTone write FNoDialTone;
property OnDialTimedOut : TNotifyEvent
read FDialTimedOut write FDialTimedOut;
property OnConnectionEstablished : TNotifyEvent
read FConnectionEstablished write FConnectionEstablished;
property OnTooManyTries : TNotifyEvent
read FTooManyTries write FTooManyTries;
{methods}
procedure Dial;
procedure Cycle;
procedure Extend(const ByHowMuch : Word);
procedure Abort;
end;
TApdModemDialer = class(TApdCustomModemDialer)
{dialing data}
property Modem;
property PhoneNumber;
property MaxDialTries;
property RetrySecs;
property DialerOptions;
{events}
property OnRetryStart;
property OnRetryCount;
property OnRetryEnd;
property OnCycleDial;
property OnDialStart;
property OnConnect;
property OnDialCount;
property OnGotLineSpeed;
property OnBusy;
property OnVoice;
property OnError;
property OnNoCarrier;
property OnNoDialTone;
property OnConnectionEstablished;
property OnTooManyTries;
end;
{.Z+}
TDialerForm = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
CycleBtn: TBitBtn;
ExtendBtn: TBitBtn;
AbortBtn: TBitBtn;
procedure CycleBtnClick(Sender: TObject);
procedure ExtendBtnClick(Sender: TObject);
procedure AbortBtnClick(Sender: TObject);
public
Labels : array[1..NumStatusLines] of TLabel;
OnLabel : Word;
Dialer : TApdCustomModemDialer;
SaveTrig : TTriggerTimerEvent;
DialTrig : Integer;
constructor Create(AOwner : TComponent); override;
procedure AddStatusString(const St : String);
{-Put a status string in the display}
procedure AddResString(const ResID : Word);
{-Load a status string from a resource and display it}
procedure DoDial(const ADialer : TApdCustomModemDialer);
{-Begin dialing}
{dialer event handlers}
procedure FrmRetryStart(Sender : TObject);
procedure FrmRetryCount(M : TObject; Remaining : Word);
procedure FrmRetryEnd(Sender : TObject);
procedure FrmDialStart(Sender : TObject);
procedure FrmConnect(Sender : TObject);
procedure FrmDialCount(M : TObject; Remaining : Word);
procedure FrmGotLineSpeed(M : TObject; Speed : LongInt);
procedure FrmBusy(Sender : TObject);
procedure FrmVoice(Sender : TObject);
procedure FrmError(Sender : TObject);
procedure FrmNoCarrier(Sender : TObject);
procedure FrmNoDialTone(Sender : TObject);
procedure FrmDialTimedOut(Sender : TObject);
procedure FrmTooManyTries(Sender : TObject);
procedure FrmConnectionEstablished(Sender : TObject);
procedure FrmTriggerTimer(CP : TObject; TriggerHandle : Word);
end;
{.Z-}
TApdDialerDialog = class(TCommonDialog)
protected {private}
{.Z+}
FModem : TApdCustomModem;
FPhoneNumber : String;
FMaxDialTries : Integer;
FRetrySecs : Integer;
FDialerOptions : TDialerOptions;
procedure Notification(AComponent : TComponent; Operation : TOperation); override;
public
constructor Create(AOwner : TComponent); override;
{.Z-}
function Execute : Boolean;
published
{dialing data}
property Modem : TApdCustomModem
read FModem write FModem;
property PhoneNumber : String
read FPhoneNumber write FPhoneNumber;
property MaxDialTries : Integer
read FMaxDialTries write FMaxDialTries default DefMaxDialTries;
property RetrySecs : Integer
read FRetrySecs write FRetrySecs default DefRetrySecs;
property DialerOptions : TDialerOptions
read FDialerOptions write FDialerOptions;
end;